package com.lhh.myspringboot.constant;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;

@AllArgsConstructor
@Getter
public enum DiscountModeEnum {

    ONE_PRICE(1,"描述1"),
    DISCOUNT(2,"描述2"),
    REDUCE(3,"描述3");


    private final Integer type;
    private final String desc;

    public static DiscountModeEnum getEnumByType(Integer type){
        if (type == null){
            return null;
        }
        return Arrays.stream(DiscountModeEnum.values())
                .filter(discountModeEnum -> discountModeEnum.type.equals(type))
                .findFirst().orElse(null);
    }
}
